<!--
 * @Author: YNT 2501512800@qq.com
 * @Date: 2022-08-06 23:09:23
 * @LastEditors: YNT 2501512800@qq.com
 * @LastEditTime: 2023-05-23 15:29:09
 * @FilePath: \20220806后台\src\views\integral\exchange.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="container" v-loading="isLoading">
    <el-card>

      <el-table :data="tableData" border>
        <el-table-column prop="user_nick_name" label="微信昵称" />
        <el-table-column prop="user_avatar_url" label="微信头像">
          <template slot-scope="{ row }">
            <el-image
              style="width: 60px; height: 60px"
              :src="row.user_avatar_url"
              :preview-src-list="[row.user_avatar_url]"
            />
          </template>
        </el-table-column>
        <el-table-column prop="balance_type_id" label="积分规则">
          <template slot-scope="{ row }">
            <div>{{rules[row.balance_type_id]}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="变化类型" />
        <el-table-column prop="current_score" label="积分变化前" />
        <el-table-column prop="changed_score" label="积分变化后" />
        <el-table-column prop="admin_user_id" label="积分来源" />
        <!-- <el-table-column prop="create_time" label="时间" /> -->
      </el-table>
    </el-card>

    <footer class="footer">
      <el-pagination
        background
        layout="total, sizes, pager, jumper"
        :current-page="searchForm.page"
        :page-sizes="[20, 30, 50, 100]"
        :page-size="searchForm.page_size"
        :total="tableTotal"
        @size-change="changeSize"
        @current-change="changeCurrent"
      />
    </footer>


  </div>
</template>

<script>
import API from "@/api";
import { table, addOrEdit } from "@/utils/mixins";
import dayjs from 'dayjs'
export default {
  mixins: [table, addOrEdit],
  data: () => ({
    isLoading:true,
    tableData:[],
    searchForm:{
      page:1,
      per_page:20,
    },
    builingForm: {
      $id: "",
      name:"",//实名信息
      score:'',//手机号
      chances_count:"",//用户地址
    },
    rules:[]
  }),

  created() {
    this.getList()
    API.getIntegralRuleList(this.searchForm)
    .then(({ data })=>{
      this.rules=data.map(item=>{
        return item.name
      })
    })
    .catch()
    .finally(()=>{
      this.isLoading=false
    })
  },

  methods: {
    // 获取随手拍列表
    getList(){
      this.isLoading=true
      API.getIntegralChangeList(this.searchForm)
      .then(({ data })=>{
        this.tableData=data.items
        this.tableTotal=data.total
      })
      .catch()
      .finally(()=>{
        this.isLoading=false
      })
    },

    // 分页
    changeSize(val){
      this.searchForm.per_page = val
      this.searchForm.page = 1
      this.getList()
    },

    // 分页
    changeCurrent(val){
      this.searchForm.page = val
      this.getList()
    },


  },
};
</script>

<style lang="scss" scoped>
</style>


